// pages/coach_mana/main.js

var con = require('../../utils/request.js')
var ui_tool = require('../../utils/uitool.js')

Page({
    data: {
        grids:[
            {
                name:"所有学员",
                icon:"/img/person.png",
                msg_count:0,
            },
            {
                name:"预约中的学员",
                icon:"/img/person.png",
                msg_count:5,
            },
            {
                name:"学时警告",
                icon:"/img/person.png",
                msg_count:5,
            },
            {
                name:"拿照学员",
                icon:"/img/person.png",
                msg_count:0,
            },
            {
                name:"待审核",
                icon:"/img/person.png",
                msg_count:5,
            },
        ],
        elements: getApp().menus
    },

    on_request_complate: function (cmd, data, status, msg) {
        wx.hideToast();
        if (status == 200) {
            if (cmd == "api/list_car") {
                console.info(data);
                this.setData({
                    list_car: data
                })
            }
            else if (cmd == "api/create_car") {
                wx.showToast({
                    title: '创建成功',
                    icon: 'success',
                    duration: 2000
                });
                this.back_list_page();
                con.remote_call("api/list_car", {}, this);
            }
        }
        else {
            ui_tool.show_error(msg);
        }
    },
    on_upload_complate: function (file, data, status, msg) {
        wx.hideToast();
        if (status == 200) {
            this.create_car(data.guid)
        }
        else {
            ui_tool.show_error(msg);
        }
    },
    on_cartype_change: function (e) {
        this.setData({
            car_type_index: e.detail.value
        })
    },
    inputChange: function (e) {
        var ids = e.target.id;
        var content = {};
        content[ids] = e.detail.value;
        this.setData(content)
    },
    onLoad: function (options) {
        // 页面初始化 options为页面跳转所带来的参数
        con.remote_call("api/list_car", {}, this);
    },
    onReady: function () {
        // 页面渲染完成
    },
    onShow: function () {
        // 页面显示

    },
    onHide: function () {
        // 页面隐藏
    },
    onUnload: function () {
        // 页面关闭
    }
})